import request from '@/utils/request';
import { QualityControlQuery } from './types';
import Qs from 'qs';
/**
 * 获取所有主播
 * @param query
 * @returns
 */
export const getAnchorList = (query: { deptId: string }) => {
  return request({
    url: '/system/user/queryList',
    method: 'get',
    params: query
  });
};
/**
 * 获取所有主播 dept
 * @param query
 * @returns
 */
export const queryOperationDeptList = () => {
  return request({
    url: '/system/dept/queryOperationDeptList',
    method: 'get',
  });
};
/**
 * 获取所有主播备份
 * @param query
 * @returns
 */
export const getDeptPage = (data: any) => {
  return request({
    url: '/stock/passer/getDeptPage',
    method: 'post',
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
    data: Qs.stringify(data),
  });
};
/**
 * 查询商品审核列表
 * @param query
 * @returns
 */
export function getHmProductsAuditList(data: QualityControlQuery) {
  return request({
    url: '/basic/pricing/getList',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
/**
 * 查询变价审核列表
 * @param query
 * @returns
 */
export function getChangeList(data: QualityControlQuery) {
  return request({
    url: '/basic/pricing/getChangeList',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
/**
 * 查询商品审核列表
 * @param query
 * @returns
 */
export function getReexamineList(data: QualityControlQuery) {
  return request({
    url: '/basic/pricing/getReexamineList',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
// 品控部查询商品审核列表
export function getQualityList(data: QualityControlQuery) {
  return request({
    url: "/basic/quality/getPcList",
    method: "post",
    data
  });
}
// PC核价一审待审核历史列表
export function getPageByTaskFirstLog(data: QualityControlQuery) {
  return request({
    url: "/basic//hmProducts/getPageByTaskFirstLog",
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
// 一审查询商品审核列表
export function getPageByTaskFirst(data: QualityControlQuery) {
  return request({
    url: "/basic/hmProducts/getPageByTaskFirst",
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
// 产品审批数据  查补样审批列表
export const getStockSampleList = (data: any) => {
  return request({
      url: '/basic/sampleAudit/getStockSampleList',
      method: 'post',
      data
  });
};
// 产品审批数据  查补样审批列表 审批历史
export const getStockSampleHistoryList = (data: any) => {
  return request({
      url: '/basic/sampleAudit/getStockSampleHistoryList',
      method: 'post',
      data
  });
};
// 产品审批数据  查补样审批列表 详情
export const getStockSampleById = (data: any) => {
  return request({
      url: '/basic/sampleAudit/getStockSampleById',
      method: 'post',
      data
  });
};
// PC核价一审查看详情
export function getDetailsById(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getFirstDetailsById",
    method: 'post',
    data
  });
}
// PC核价一审审核
export function auditFirst(data: any) {
  return request({
    url: "/basic/hmProducts/auditFirst",
    method: 'post',
    data
  });
}
// 产品app 点击 审批数据  查补样审批列表 详情 驳回
export const sampleAuditrefuse = (data: any) => {
  return request({
      url: '/basic/sampleAudit/refuse',
      method: 'post',
      data
  });
};

// 产品app 点击 审批数据  查补样审批列表 详情 通过
export const sampleAuditpass = (data: any) => {
  return request({
      url: '/basic/sampleAudit/pass',
      method: 'post',
      data
  });
};
// 二审查询商品审核列表
export function getPageByTaskSecond(data: QualityControlQuery) {
  return request({
    url: "/basic/hmProducts/getPageByTaskSecond",
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
// 二审查询商品审核历史列表
export function getPageByTaskSecondLog(data: QualityControlQuery) {
  return request({
    url: "/basic/hmProducts/getPageByTaskSecondLog",
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
// PC核价二审查看详情
export function getSecondDetailsById(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getSecondDetailsById",
    method: 'post',
    data
  });
}
// 品控审批历史
export function getPcHistoryList(data: QualityControlQuery) {
  return request({
    url: "/basic/quality/getPcHistoryList",
    method: "post",
    data
  });
}
/**
 * 查询商品审核历史
 * @param query
 * @returns
 */
export function historyList(data: QualityControlQuery) {
  return request({
    url: '/basic/pricing/historyList',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
/**
 * app/pc待核价查看详情
 * @param query
 * @returns
 */
export function getPricingId(data: { id: string, pageNum: number, pageSize: number }) {
  return request({
    url: '/basic/pricing/id',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
/**
 * app/品控查看详情
 * @param query
 * @returns
 */
export function getQualityId(data: { id: any }) {
  return request({
    url: '/basic/quality/id',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
/**
 * app/pc核价历史查看详情
 * @param query
 * @returns
 */
export function getHistoryId(id: any) {
  return request({
    url: `/basic/pricing/getHistoryId/${id}`,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post'
  });
}
/**
 * 审核成功
 * @param data
 */
export const pass = (data: { auditDept: number; id: string; productsId: string }) => {
  return request({
    url: '/basic/pricing/pass',
    method: 'post',
    data: data
  });
};

/**
 * 审核失败
 * @param data
 */
export const refuse = (data: { auditDept: number; id: string; productsId: string; auditRemark: string }) => {
  return request({
    url: '/basic/pricing/refuse',
    method: 'post',
    data: data
  });
};

/**
 * app 品控审核成功
 * @param data
 */
export const qualityPass = (data: { auditDept: number; id: string; productsId: string }) => {
  return request({
    url: '/basic/quality/pass',
    method: 'post',
    data: data
  });
};
/**
 * app品控审核失败
 * @param data
 */
export const qualityRefuse = (data: { auditDept: number; id: string; productsId: string; auditRemark: string }) => {
  return request({
    url: '/basic/quality/refuse',
    method: 'post',
    data: data
  });
};

/**
 * 新-查询变价审核列表
 * @param query
 * @returns
 */
export function getPricingList(data: QualityControlQuery) {
  return request({
    url: '/basic/changeAudit/getPricingList',
    method: 'post',
    data: data
  });
}

/**
 * 新-查询变价历史列表
 * @param query
 * @returns
 */
export function getPricingHistoryList(data: QualityControlQuery) {
  return request({
    url: '/basic/changeAudit/getPricingHistoryList',
    method: 'post',
    data: data
  });
}


/**
 * 新-变价审批详情
 * @param query
 * @returns
 */
export function getPricingById(data: any) {
  return request({
    url: '/basic/changeAudit/getPricingById',
    method: 'post',
    data: data
  });
}


// 组长初审列表
export function groupAuditList(data: any) {
  return request({
    url: "/basic/hmProducts/groupAuditList",
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
// 组长初审列表查看详情
export function getFirstDetailsByIdInvent(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getFirstDetailsByIdInvent",
    method: 'post',
    data
  });
}

// 组长初审历史列表
export function getFirstLogInvent(data: QualityControlQuery) {
  return request({
    url: "/basic/hmProducts/getFirstLogInvent",
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
// 总监初审列表
export function getSecondListInvent(data: any) {
  return request({
    url: "/basic/hmProducts/getSecondListInvent",
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
// 总监初审列表查看详情
export function getSecondDetailsByIdInvent(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getSecondDetailsByIdInvent",
    method: 'post',
    data
  });
}
// 总监初审历史列表
export function getSecondLogInvent(data: QualityControlQuery) {
  return request({
    url: "/basic/hmProducts/getSecondLogInvent",
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}

// 总监复审初审列表
export function getThirdListInvent(data: any) {
  return request({
    url: "/basic/hmProducts/getThirdListInvent",
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}
// 总监复审详情
export function getThirdDetailsByIdInvent(data: { id: string }) {
  return request({
    url: "/basic/hmProducts/getThirdDetailsByIdInvent",
    method: 'post',
    data
  });
}

// 总监复审历史列表
export function getThirdLogInvent(data: QualityControlQuery) {
  return request({
    url: "/basic/hmProducts/getThirdLogInvent",
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    method: 'post',
    data: Qs.stringify(data)
  });
}

// 审批中心商品详情
export function getProductDetailed(data: any) {
  return request({
    url: "/basic/examine/getProductDetailed",
    method: 'post',
    data
  });
}

// 审批中心无合同详情
export function contractAudit(data: any) {
  return request({
    url: `/basic/contractAudit/${data.id}`,
    method: 'get'
  });
}


